//
//  MLWMenuCollectionViewCell.m
//  KITCHEN_STORIES
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 MLW. All rights reserved.
//

#import "MLWMenuCollectionViewCell.h"

@implementation MLWMenuCollectionViewCell

- (void)dealloc
{
    [_topLabel release];
    [_imageView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        
        //给imageView加圆角属性:
        self.imageView.layer.cornerRadius = 10;
        self.imageView.clipsToBounds = YES;        //剪切
        
        //self.imageView.layer.masksToBounds = YES;
        
        
        //渐变 (有点丑)
        self.viewNice = [[UIView alloc] initWithFrame:CGRectMake(0, self.imageView.frame.size.height - 15, self.imageView.frame.size.width, 15)];
        
        CAGradientLayer *colorLayer = [CAGradientLayer layer];
        colorLayer.frame = self.viewNice.bounds;
        [self.viewNice.layer addSublayer:colorLayer];
        //颜色分配
        colorLayer.colors = @[(__bridge id)[UIColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:0.1].CGColor, (__bridge id)[UIColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:0.5].CGColor];
        
        //颜色分割线
        colorLayer.locations = @[@(0), @(1)];
        
        //起始点
        colorLayer.startPoint = CGPointMake(0, 0);
        
        //结束点
        colorLayer.endPoint = CGPointMake(1, 1);
        
        
        //设定label的基本属性:

        self.topLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageView.frame.size.height - 15, self.imageView.frame.size.width, 15)];
        
       // self.topLabel.backgroundColor = [UIColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:0.4];
        self.topLabel.textColor = [UIColor whiteColor];
        self.topLabel.font = [UIFont systemFontOfSize:12];
        self.topLabel.textAlignment = 1;
      
        [self.imageView addSubview:_viewNice];
        [self.imageView addSubview:_topLabel];
        [self.contentView addSubview:_imageView];
        [_topLabel release];
        [_imageView release];
        
   
        
        
    }
    return self;
}





@end
